home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / netprog.zip / NETPROG.TAR / ipc / getpwd.c < prev    next >
C/C++ Source or Header  |  1989-12-17  |  299b  |  21 lines

  1. #include    <stdio.h>
  2.  
  3. #define    MAXLINE        255
  4.  
  5. main()
  6. {
  7.     FILE    *fp;
  8.     char    line[MAXLINE];
  9.  
  10.     if ( (fp = popen("/bin/pwd", "r")) == NULL)
  11.         err_sys("popen error");
  12.  
  13.     if (fgets(line, MAXLINE, fp) == NULL)
  14.         err_sys("fgets error");
  15.  
  16.     printf("%s", line);    /* pwd inserts the newline */
  17.  
  18.     pclose(fp);
  19.     exit(0);
  20. }
  21.